package com.guaoran.interview.in2018;

/**
 * @Author gucheng
 * @Description
 *  String
 * 2019-03-18 18:06
 */
public class StringDemo {
    public static void main(String[] args) {
        String s1 = "Programming";
        String s2 = new String("Programming");
        String s3 = "Program";
        String s4 = "ming";
        String s5 = "Program" + "ming";
        String s6 = s3 + s4;
        //false
        System.out.println(s1 == s2);
        //true  :String是final修饰的，每次改变都是一个新的，但是如果这个新的值已经存在则不会在进行创建新的，而是引用
        System.out.println(s1 == s5);
        //false :底层通过StringBuilder.append -> toString
        System.out.println(s1 == s6);
        String s = "==========";
        System.out.println(s1 == s6.intern()); //true ????
        System.out.println(s2 == s2.intern()); //false ????

    }
}
